//
//  KSSupplierManageTableViewCell.swift
//  Supermarket
//
//  Created by Black_Crystal on 2017/9/28.
//  Copyright © 2017年 kushao. All rights reserved.
//

import UIKit

class KSSupplierManageTableViewCell: UITableViewCell {
    
    private let headImg = UIImageView()
    private let titleLabel = UILabel()
    private let detailLabel = UILabel()
    private let numberLabel = UILabel()
    private let txtLabel = UILabel()
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = UIColor.white
        self.selectionStyle = .none
        
        self.contentView.addSubview(headImg)
        headImg.snp.makeConstraints { (make) in
            make.top.left.equalTo(10)
            make.width.height.equalTo(60)
        }
        
        titleLabel.text = "供应商:asdbasjdhas"
        titleLabel.font = UIFont.systemFont(ofSize: 16)
        titleLabel.textColor = KSColor.kColor_3
        self.contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.top.equalTo(10)
            make.left.equalTo(headImg.snp.right).offset(10)
        }
        
        let rightView = UIView()
        self.contentView.addSubview(rightView)
        rightView.snp.makeConstraints { (make) in
            make.top.bottom.right.equalTo(0)
            make.width.equalTo(50)
        }
        
        numberLabel.text = "7"
        numberLabel.font = UIFont.systemFont(ofSize: 17)
        numberLabel.textColor = KSColor.kColor_3
        rightView.addSubview(numberLabel)
        numberLabel.snp.makeConstraints { (make) in
            make.top.equalTo(20)
            make.centerX.equalToSuperview()
        }
        
        txtLabel.text = "上新"
        txtLabel.textColor = KSColor.kColor_9
        txtLabel.font = UIFont.systemFont(ofSize: 15)
        rightView.addSubview(txtLabel)
        txtLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(numberLabel)
            make.bottom.equalTo(self.contentView.snp.bottom).offset(-20)
        }
        
        detailLabel.text = "汪汪汪汪汪无无无无汪汪汪汪汪无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无无"
        detailLabel.numberOfLines = 2
        detailLabel.textColor = KSColor.kColor_9
        detailLabel.font = UIFont.systemFont(ofSize: 14)
        self.contentView.addSubview(detailLabel)
        detailLabel.snp.makeConstraints { (make) in
            make.top.equalTo(titleLabel.snp.bottom).offset(5)
            make.right.equalTo(rightView.snp.left)
            make.left.equalTo(headImg.snp.right).offset(10)
        }
        
        let lineView = UIView()
        lineView.backgroundColor = KSColor.kColor_line
        self.contentView.addSubview(lineView)
        lineView.snp.makeConstraints { (make) in
            make.bottom.right.equalTo(0)
            make.height.equalTo(1)
            make.left.equalTo(70)
        }
    }
    
    func setDataWithModel(model: KSSupplierManageDataListModel) {
        headImg.sd_setImage(with: URL.init(string: model.photo_logo), placeholderImage: UIImage.init(named: "Common_PeoplePlace"))
        titleLabel.text = "经销商:\(model.name)"
        detailLabel.text = "\(model.intro.isEmpty ? "描述：无" : model.intro)"
        numberLabel.text = "\(model.news)"
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
